var Camera=function(Value)
	{
	fastCSharp.Copy(this,Value);
	this.OnLoad=fastCSharp.Event().Add(this.OnLoad);
	this.OnError=fastCSharp.Event().Add(this.OnError);
	this.Camera=fastCSharp.$Id(this.Id).GetElements()[0];
	if(navigator.getUserMedia)
		{
		navigator.getUserMedia({video:true},fastCSharp.ThisFunction(this,this.Load),fastCSharp.ThisFunction(this,this.LoadError));
		}
	else if(navigator.webkitGetUserMedia)
		{
		navigator.webkitGetUserMedia({video:true},fastCSharp.ThisFunction(this,this.Load,[(window.URL||window.webkitURL).createObjectURL]),fastCSharp.ThisFunction(this,this.LoadError));
		}
	else if(navigator.mozGetUserMedia)
		{
		navigator.mozGetUserMedia({video:true},fastCSharp.ThisFunction(this,this.Load,[window.URL.createObjectURL]),fastCSharp.ThisFunction(this,this.LoadError));
		}
	else	this.LoadError();
	};
Camera.prototype={
LoadError:function()
	{
	this.OnError();
	},
Load:function(Stream,GetSrc)
	{
	this.Camera.src=GetSrc?GetSrc(Stream):GetSrc;
	this.Camera.play();
	this.OnLoad();
	},
DataURLtoBlob:function(DataUrl)
	{
	var Array=DataUrl.split(','),String=atob(Array[1]),Code=new Uint8Array(String.length);
	for(var Size=String.length;Size--;Code[Size]=String.charCodeAt(Size));
	return new Blob([Code],{type:Array[0].match(/:(.*?);/)[1]});
	},
DrawImage:function(CanvasId,Left,Top,Width,Height)
	{
	var Canvas=fastCSharp.$Id(CanvasId).GetElements()[0],Image=Canvas.getContext('2d');
	Image.drawImage(this.Camera,Left,Top,Width,Height);
	return Image;
	},
ToCanvasImageBlob:function(CanvasId,Left,Top,Width,Height,Quality)
	{
	this.DrawImage(CanvasId,Left,Top,Width,Height);
	return this.GetCanvasImageBlob(CanvasId,Quality);
	},
GetCanvasImageBlob:function(CanvasId,Quality)
	{
	var Image=fastCSharp.$Id(CanvasId).GetElements()[0];
	return this.DataURLtoBlob(Quality?Image.toDataURL('image/jpeg',Quality):Image.toDataURL('image/jpeg'));
	}
		};